package cn.edu.scau.cmi.chenjia.clientFxml;

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.control.TextArea;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import cn.edu.scau.cmi.chenjia.adapter.Student;
import cn.edu.scau.cmi.chenjia.adapter.Target;
import cn.edu.scau.cmi.chenjia.adapter.classAdapter;
import cn.edu.scau.cmi.chenjia.adapter.objectAdapter;

public class AdapterUIController {
	
	@FXML
	private Button btn_1;
	@FXML
	private Button btn_2;
	@FXML
	private Label lab_1;
	@FXML
	private Label lab_2;
	@FXML
	private TextField text_1;
	@FXML
	private TextField text_2;
	@FXML
	private TextArea text_3;
	
	ArrayList<Student> studentList = new ArrayList<Student>();
		public void eventButton1(){
			Student st=new Student();
			st.name=text_1.getText();
			st.number=Integer.parseInt(text_2.getText());
			studentList.add(st);
			Target ca=new classAdapter();
			studentList=ca.sortStudent(studentList);
			String  s="Welcome to use classAdapter method!";
			text_3.setText(s+'\n');
			for(int i=0;i<studentList.size();i++) {
				text_3.appendText(studentList.get(i).name+'\t'+studentList.get(i).number+'\n');
			}
		}
		
		public void eventButton2(){
			Student st=new Student();
			st.name=text_1.getText();
			st.number=Integer.parseInt(text_2.getText());
			studentList.add(st);
			Target ca=new objectAdapter();
			studentList=ca.sortStudent(studentList);
			String  s="Welcome to use objectAdapter method!";
			text_3.setText(s+'\n');
			for(int i=0;i<studentList.size();i++) {
				text_3.appendText(studentList.get(i).name+'\t'+studentList.get(i).number+'\n');
			}
		}

}
